import 'package:common_utils/common_utils.dart';
import 'package:get/get.dart';

import '../../models/ftpcmd.dart';
import '../../utils/sp.dart';
import 'state.dart';

class HomeLogic extends GetxController {
  final HomeState state = HomeState();

  saveSp() async {
    final data = [
      FtpCommand(cmd: "111", body: FtpBody(host: "111")),
      FtpCommand(cmd: "222", body: FtpBody(host: "222")),
      FtpCommand(cmd: "333", body: FtpBody(host: "333"))
    ];
    await SpUtil.put("list", data);
    final list = await SpUtil.getObj("list");
    LogUtil.e(list);

    await SpUtil.put("map", FtpCommand(cmd: "111", body: FtpBody(host: "222")));
    final map = await SpUtil.getObj("map");
    final aaa = JsonUtil.getObject(map, (v) => FtpCommand.fromJson(v as Map<String, dynamic>));
    LogUtil.e(aaa);

    final test = await SpUtil.getObj("12321312");
    LogUtil.e(test == null);
  }
}
